﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Register.aspx.cs" Inherits="BlogDH.Register" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>用户注册-博客导航</title>
    <link href="../Css/login.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <form id="form1" action="register.aspx" method="post">
    <div class="nav">
        <a href="index.aspx">返回首页</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="login.aspx">返回登录</a>
    </div>
    <div class="content">
        <label class="label">
            博客域名：</label>
        <input type="text" id="uname" name="uname" maxlength="50" value="<%=username %>"
            onfocus="if(this.value=='如:blogdh.com') this.value=''" onblur="checkDomain();" />
        <div class="clear">
        </div>
        <label class="label">
            设置密码：</label>
        <input type="password" id="pwd" name="pwd" maxlength="20" />
        <div class="clear">
        </div>
        <label class="label">
            确认密码：</label>
        <input type="password" id="spwd" name="spwd" />
        <div class="clear">
        </div>
        <span id="error">
            <%=errorStr %></span>
        <br />
        <br />
        <input type="submit" class="button" name="commit" value="注册" onclick="return gosubmit();" /></div>
    </form>
    <br />
    <br />
    <br />
    <script type="text/javascript">
        function gosubmit() {
            var ret = false;
            if (checkDomain()) {
                if (document.getElementById("pwd").value != document.getElementById("spwd").value) {
                    document.getElementById("error").innerHTML = "两次密码输入不一致";
                } else {
                    ret = true;
                }
            }
            return ret;
        }

        function checkDomain() {
            var domain = document.getElementById("uname").value.replace("http://", "").replace("www.", "");
            if (domain == "") {
                var domain = document.getElementById("uname").value = "如:blogdh.com";
                document.getElementById("error").innerHTML = "请输入域名";
                return false;
            } else if (domain == "如:blogdh.com") {
                document.getElementById("error").innerHTML = "请输入域名";
                return false;
            }
            document.getElementById("uname").value = domain;
            var patrn = /^[0-9a-zA-Z]+[0-9a-zA-Z\.-]*\.[a-zA-Z]{2,4}$/;
            if (patrn.test(domain)) {
                return true;
            } else {
                document.getElementById("error").innerHTML = "域名格式输入错误";
                return false;
            }
        }
    </script>
</body>
</html>
